package com.example.denglu.controller;

import com.example.denglu.entity.UserInformation;
import com.example.denglu.service.imp.UserInformationServiceImp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "个人信息模块")
@RestController
@RequestMapping("/UserInformation")
public class UserInformationController {
    @Autowired
    UserInformationServiceImp userInformationService;

   //插入信息
    @ApiOperation(value = "录入信息")
    @PostMapping("/add")
    public String  add(@RequestBody @Valid  UserInformation userInformation){
        return userInformationService.add(userInformation);
    }

    //根据姓名查找
    @ApiOperation(value = "根据姓名查找")
    @PostMapping("/SelectByName")
    public  UserInformation SelectByName(@RequestBody  UserInformation userInformation){
        return userInformationService.SelectByName(userInformation.getName());
    }

    //根据性别查找
    @ApiOperation(value = "根据性别查找")
    @PostMapping("/SelectByGender")
    public List<UserInformation> SelectByGender(@RequestBody  UserInformation userInformation){
        return userInformationService.SelectByGender(userInformation.getGender());
    }

    //根据职位查找
    @ApiOperation(value = "根据职位查找")
    @PostMapping("/SelectByPosition")
    public  List<UserInformation> SelectByPosition(@RequestBody UserInformation userInformation){
        return userInformationService.SelectByPosition(userInformation.getPosition());
    }

    //删除记录
    @ApiOperation(value = "删除信息")
    @PostMapping("/DeleteByname")
    public  String DeleteByName(@RequestBody  UserInformation userInformation){
        return userInformationService.DeleteByName(userInformation.getName());
    }



    //显示全部记录
    @ApiOperation(value ="显示全部记录" )
    @PostMapping("/FindAll")
    public List<UserInformation> FindAll(){
        return userInformationService.FindAll();
    }

   //模糊查询
    @ApiOperation(value ="搜索" )
    @PostMapping("/FindKeyWord")
    public List<UserInformation> FindKeyWord(@RequestBody String keyWord){
        return userInformationService.FindKeyWord(keyWord);
    }

}
